package com.example.yskjproject.model;

import android.os.Parcelable;

import android.os.Parcel;
import android.os.Parcelable;

public class RechargeModel implements Parcelable {

    private int state;
    private String msg;
    private PayInfo pay_info;

    // 构造函数
    public RechargeModel(int state, String msg, PayInfo pay_info) {
        this.state = state;
        this.msg = msg;
        this.pay_info = pay_info;
    }

    // Getter 和 Setter
    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public PayInfo getPay_info() {
        return pay_info;
    }

    public void setPay_info(PayInfo pay_info) {
        this.pay_info = pay_info;
    }

    // Parcelable 实现
    protected RechargeModel(Parcel in) {
        state = in.readInt();
        msg = in.readString();
        pay_info = in.readParcelable(PayInfo.class.getClassLoader());
    }

    public static final Creator<RechargeModel> CREATOR = new Creator<RechargeModel>() {
        @Override
        public RechargeModel createFromParcel(Parcel in) {
            return new RechargeModel(in);
        }

        @Override
        public RechargeModel[] newArray(int size) {
            return new RechargeModel[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(state);
        dest.writeString(msg);
        dest.writeParcelable(pay_info, flags);
    }

    // 嵌套的 PayInfo 类
    public static class PayInfo implements Parcelable {

        private String pay_url;
        private String expire_time;

        // 构造函数
        public PayInfo(String pay_url, String expire_time) {
            this.pay_url = pay_url;
            this.expire_time = expire_time;
        }

        // Getter 和 Setter
        public String getPay_url() {
            return pay_url;
        }

        public void setPay_url(String pay_url) {
            this.pay_url = pay_url;
        }

        public String getExpire_time() {
            return expire_time;
        }

        public void setExpire_time(String expire_time) {
            this.expire_time = expire_time;
        }

        // Parcelable 实现
        protected PayInfo(Parcel in) {
            pay_url = in.readString();
            expire_time = in.readString();
        }

        public static final Creator<PayInfo> CREATOR = new Creator<PayInfo>() {
            @Override
            public PayInfo createFromParcel(Parcel in) {
                return new PayInfo(in);
            }

            @Override
            public PayInfo[] newArray(int size) {
                return new PayInfo[size];
            }
        };

        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeString(pay_url);
            dest.writeString(expire_time);
        }
    }
}
